﻿#region Imports
using System;
using System.Globalization;
using System.Windows.Data;
#endregion

namespace LinqDemo.Converters
{
    public class InversionConverter : IValueConverter
    {
        #region Methods
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            switch ((string)parameter)
            {
                case "bool":
                    return Utilities.Utilities.IsBoolean(value) ? !System.Convert.ToBoolean(value) : false;
                default:
                    return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            switch ((string)parameter)
            {
                case "bool":
                    return Utilities.Utilities.IsBoolean(value) ? !System.Convert.ToBoolean(value) : false;
                default:
                    return null;
            }
        }
        #endregion
    }
}
